<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0 minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>问卷预览</title>
    <link href="public/css/header.css" rel="stylesheet" type="text/css">
    <link href="public/css/container.css" rel="stylesheet" type="text/css">
    <script src="../public/jQuery/jQuery-2.1.3.min.js"></script>
    <script src="../public/js/publicjs.js"></script>
    <script src="../public/js/extend.js"></script>
    <script src="public/js/myjs/whole.js"></script>

    <script src="mobiscroll/js/mobiscroll.core-2.5.2.js" type="text/javascript"></script>

    <script src="mobiscroll/js/mobiscroll.core-2.5.2-zh.js" type="text/javascript"></script>

    <link href="mobiscroll/css/mobiscroll.core-2.5.2.css" rel="stylesheet" type="text/css"/>
    <link href="mobiscroll/css/mobiscroll.animation-2.5.2.css" rel="stylesheet" type="text/css"/>
    <script src="mobiscroll/js/mobiscroll.datetime-2.5.1.js" type="text/javascript"></script>
    <script src="mobiscroll/js/mobiscroll.datetime-2.5.1-zh.js" type="text/javascript"></script>

    <link href="public/css/answer.css" rel="stylesheet" type="text/css"/>
    <style>
        .question-delete{
            text-align: center;
            padding-top: 20vh;
            font-size: 3vh;
        }
    </style>
</head>
<body>

<header>
    <div class="header__box tl">

        <img onclick="exit()" src="public/img/basic/back.png"/>
        <span onclick="exit()" class="back">返回</span>

    </div>
    <div class="header__box tc header__box__title">
        问卷填写
    </div>
    <div class="header__box tr share">
        <span class="newCreate">分享</span>
    </div>
    <div class="pop-up">
    </div>
</header>

<div class="call_back">
    <div class="pop">
        <div class="publish_loading_div_l">
            <img style="width: 10vw;height: 10vw;" src='public/img/basic/loading.gif'>
        </div>
        <div class="publish_loading_div_r">
            正在提交问卷
        </div>
    </div>
</div>

<section class="section">
    <!--发布时动效-->
    <div class="text_no_more">
        <img class="loading" src='public/img/basic/loading.gif'>
    </div>
    <div id="content">
    </div>
    <div class="btnPublish" style="display: none;">
        <span>
            提交
        </span>
    </div>

    <div class="moreDiv" style="width: 100%;height: 43vh;display: none;">

    </div>

    <input type="hidden" id="questionnaire_id"/>
    <input type="hidden" id="questionnaire_name"/>
    <input type="hidden" id="questionnaire_welcome"/>
    <input type="hidden" id="group_id"/>
</section>

</body>
</html>
<script>

    var index;
    $(function () {
        $.getUrlParam = function (name) {
            var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
            var r = window.location.search.substr(1).match(reg);
            if (r != null) return unescape(r[2]);
            return null;
        };
        var questionnaire_id = $.getUrlParam('questionnaire_id');
        var userId = $.getUrlParam('userId');
        var group_id2 = $.getUrlParam('group_id');

        //如果用用户id传过来,表示从安卓页面跳转过来的
        if (userId == null) {
            index = false;
        }
        else {
            index = true;
        }
        API_Func('/questionnaires/' + questionnaire_id, "GET", {id: questionnaire_id}, true, function () {

        }, function (d) {
            var data = d.data;

            if(d.code==1){

              $(".section").empty().append("<div class='question-delete'>该问卷已被删除</div>");

            }

            if (d.code == 0) {
                $(".btnPublish").css('display','block');
                var html = "";
                html += '<div class="content_title"><span class="content_title_span">' + data.questionnaire_name +
                        '</span>' +
                        '</div>' +
                        '<div class="content_welcome">' +
                        '<span class="content_welcome_span">' + data.questionnaire_welcome +
                        '</span>' +
                        '</div>';
                for (var i = 0; i < data.questions.length; i++) {

                    //单选题
                    if (data.questions[i].question_type == 0) {
                        html += '<div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="0" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';
                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }
                        html += '</div>' +
                                '<div style="clear: both;">' +

                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }
                        html += '</div>';
                        html += '<ul class="single">';

                        //单项选项遍历
                        var question_options = data.questions[i].question_options.split(',');
                        for (var j = 0; j < question_options.length; j++) {
                            html += '<li>' +
                                    '<div class="option">' +
                                    '<img data-select_true="0" data-index="' + j + '" src="public/img/preview/ellipse.png" />' +
                                    '</div>' +

                                    '<div class="text_div_option">' + question_options[j]
                                    +
                                    '</div>' +
                                    '<div style="clear: both;">' +

                                    '</div>' +
                                    '</li>';
                        }
                        html += '</ul>' +
                                '</div>';
                    }

                    //多选题
                    else if (data.questions[i].question_type == 1) {
                        html +=
                                '<div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="1" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';
                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }
                        if (data.questions[i].select_limit != 0) {
                            html += '<span class="bg_323232">(最多选' + data.questions[i].select_limit + '个)</span>';
                        }
                        html += '</div>' +
                                '<div style="clear: both;">' +

                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }

                        html += '</div>';
                        html += '<ul class="multiple" data-select_limit="' + data.questions[i].select_limit + '" data-select_count=0>';

                        //单项选项遍历
                        var question_options = data.questions[i].question_options.split(',');
                        for (var j = 0; j < question_options.length; j++) {

                            html += '<li>' +
                                    '<div class="option">' +
                                    '<img data-select_true="0" data-index="' + j + '" src="public/img/preview/checkbox_no_select.png" />' +
                                    '</div>' +

                                    '<div class="text_div_option">' + question_options[j] +
                                    '</div>' +
                                    '<div style="clear: both;">' +

                                    '</div>' +
                                    '</li>';

                        }

                        html += '</ul>' +
                                '</div>';
                    }

                    //填空题
                    else if (data.questions[i].question_type == 2) {
                        html += '<div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="2" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';

                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }

                        html += '</div>' +
                                '<div style="clear: both;">' +
                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }

                        html += '</div>';
                        html += '<div class="grade">' +
                                '<textarea class="desc" rows="' + data.questions[i].rows + '"></textarea>' +
                                '</div>' +
                                '</div>';
                    }

                    //打分题
                    else if (data.questions[i].question_type == 3) {
                        html += ' <div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="3" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';

                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }

                        html += '</div>' +
                                '<div style="clear: both;">' +

                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }

                        html += '</div>';
                        html += '<div class="play_score">' +
                                '<span>' +
                                '请打分 (满分' + data.questions[i].mark_limit + '分)' +
                                '</span>' +
                                '</div>' +
                                '<div class="score" data-score="0">';

                        for (var j = 0; j < data.questions[i].mark_limit; j++) {
                            html += '<div>' +
                                    '<img class="score_img" src="public/img/preview/score_no_select.png" />' +
                                    '</div>';
                        }

                        html += '</div>' +
                                '</div>';
                    }

                    //日期题
                    else if (data.questions[i].question_type == 4) {
                        html += '<div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="4" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';
                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }
                        html += '</div>' +
                                '<div style="clear: both;">' +

                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }

                        html += '</div>';
                        html += '<div class="date">' +
                                '<div class="date_input">' +
                                '<input readonly="readonly" type="text" placeholder="请选择"/>' +
                                '</div>' +
                                '<div class="date_img">' +
                                '<img class="date_show" src="public/img/preview/date.png" />' +
                                '</div>' +
                                '</div>' +
                                '</div>';
                    }

                    //时间题
                    else if (data.questions[i].question_type == 5) {
                        html += ' <div class="content_question" data-question_id="' + data.questions[i].question_id + '" data-type="5" data-necessary="' + data.questions[i].is_necessary + '">' +
                                '<div class="content_question_title bg_323232">' + data.questions[i].question_body +
                                '</div>' +
                                '<div class="content_question_title_ness bg_FF4C4C">';
                        if (data.questions[i].is_necessary == 1) {
                            html += '*';
                        }

                        html += '</div>' +
                                '<div style="clear: both;">' +

                                '</div>';
                        //图片
                        var question_img = data.questions[i].question_img.split(',');
                        html += ' <div style="position: relative;width: 100%;text-align: center;">';

                        for (var k = 0; k < question_img.length; k++) {
                            if (question_img[k] != "") {
                                html += '<img class="preview_img" src="' + question_img[k] + '">';
                            }

                        }

                        html += '</div>';
                        html += '<div class="time">' +
                                '<div class="time_input">' +
                                '<input readonly="readonly" type="text" placeholder="请选择"/>' +
                                '</div>' +
                                '<div class="time_img">' +
                                '<img class="time_show" src="public/img/preview/time.png" />' +
                                '</div>' +
                                '</div>' +
                                '</div>';
                    }
                }

                var questionnaire_id = data.questionnaire_id;
                var questionnaire_name = data.questionnaire_name;
                var questionnaire_welcome = data.questionnaire_welcome;

                $("#questionnaire_id").val(questionnaire_id);
                $("#questionnaire_name").val(questionnaire_name);
                $("#questionnaire_welcome").val(questionnaire_welcome);

                $(".share").on('click', function () {
                    var group_id3 = group_id2 == null ? group_id : group_id2;
                    shareContent("", group_id3, questionnaire_welcome, questionnaire_name, "", 3, "", "/questionnaire/answer.html?questionnaire_id=" + questionnaire_id + "&group_id=" + group_id3)
                });

                //添加标签
                $("#content").append(html);
                //加载消失
                $(".text_no_more").css('display', 'none');

                //单选操作
                $('.content_question .single .option img').on('click', function () {

                    $(this).parents('li').siblings().find('img').attr('src', 'public/img/preview/ellipse.png');
                    $(this).parents('li').siblings().find('img').attr('data-select_true', 0);
                    $(this).attr('src', 'public/img/preview/ellipse2.png');
                    $(this).attr('data-select_true', 1);

                    //如果有提示框的,把它隐藏
                    hideprev($(this));

                });

                //多选操作
                $('.content_question .multiple .option img').on('click', function () {
                    var _self = $(this);
                    //最多选择
                    var select_limit = _self.parents('.multiple').attr('data-select_limit').trim();
                    var select_count = _self.parents('.multiple').attr('data-select_count').trim();

                    //判断它是否之前被选中过
                    var selete_true = _self.attr('data-select_true');

                    //如果之前没有选中过
                    if (selete_true == 0) {
                        select_count = parseInt(select_count) + 1;

                        if (select_count > select_limit && select_limit != 0) {

                            pop_up_fn($('.pop-up'), '最多只能选' + select_limit + '个')
                        }
                        else {
                            _self.parents('.multiple').attr('data-select_count', select_count);
                            _self.attr('data-select_true', 1);
                            _self.attr('src', 'public/img/preview/checkbox_select.png');
                        }
                    }
                    //如果之前没有选中过
                    else {
                        select_count = parseInt(select_count) - 1;
                        _self.parents('.multiple').attr('data-select_count', select_count);
                        _self.attr('data-select_true', 0);
                        _self.attr('src', 'public/img/preview/checkbox_no_select.png');
                    }

                    //如果有提示框的,把它隐藏
                    hideprev(_self);
                });

                //填空题
                $('textarea').on('input', function () {

                    var _self = $(this);

                    //如果有提示框的,把它隐藏
                    hideprev(_self);
                });

                //打分题
                $('.content_question .score img').on('click', function () {
                    var _self = $(this);
                    _self.attr('src', 'public/img/preview/score_select.png');
                    _self.parent().prevAll().children('img').attr('src', 'public/img/preview/score_select.png');
                    _self.parent().nextAll().children('img').attr('src', 'public/img/preview/score_no_select.png');

                    var score_count = 0;
                    score_count = score_count + 1 + _self.parent().prevAll().length;
                    _self.parents('.score').attr('data-score', score_count);

                    //如果有提示框的,把它隐藏
                    hideprev(_self);

                });

                selectDate($(".content_question .date .date_input input"));
                selectTime($(".content_question .time .time_input input"));

                $('.date_show').on('click', function () {
                    $(this).parents('.date').find('input').trigger("focus");
                    hideprev($(this));
                });

                $('.time_show').on('click', function () {
                    $(this).parents('.time').find('input').trigger("focus");
                    hideprev($(this));
                })
            }

        });

        //提交
        $('.btnPublish').on('click', function () {

            var questionnaire_id = $('#questionnaire_id').val();

            var answerList = [];
            var send_data = {
                questionnaire_id: questionnaire_id,
                user_id: user_id.toString(),
                answerList: answerList
            };
            if (index) {
                send_data.user_id = userId;
            }
            console.log(send_data.user_id);

            //控制提交API
            var is_send_api = true;

            //
            $('.content_question').each(function () {

                var _self = $(this);

                //是否必填
                var necessary = _self.attr('data-necessary');
                //如果是单选题
                if (_self.attr('data-type') == 0) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    //用count来判断它有没有填写
                    var count = 0;

                    $(this).find('img').each(function () {

                        if ($(this).attr('data-select_true') == 1) {
                            count++;
                            answer = $(this).attr('data-index');
                        }
                    });

                    if (necessary == 1) {
                        if (count <= 0) {
                            is_send_api = false;
                            var html = '<div class="ness">请选择单选!</div>';
                            showprev(_self, html);
                        }
                        else {

                            var data = {
                                question_id: question_id,
                                answer: answer
                            };

                            answerList.push(data);
                        }
                    }
                    else {
                        if (count <= 0) {

                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }
                //如果是多选题
                else if (_self.attr('data-type') == 1) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    //用count来判断它有没有填写
                    var count = 0;

                    $(this).find('img').each(function () {

                        if ($(this).attr('data-select_true') == 1) {
                            count++;
                            answer += $(this).attr('data-index') + ",";
                        }
                    });

                    if (necessary == 1) {
                        if (count <= 0) {
                            is_send_api = false;
                            var html = '<div class="ness">请选择多选!</div>';
                            showprev(_self, html);
                        }
                        else {
                            answer = answer.substr(0, answer.length - 1);
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                    else {
                        if (count <= 0) {

                        }
                        else {
                            answer = answer.substr(0, answer.length - 1);
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }

                //如果是填空题
                else if (_self.attr('data-type') == 2) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    //用count来判断它有没有填写
                    var count = 0;

                    answer = $(this).find('textarea').val().trim();

                    if (necessary == 1) {
                        if (answer == "" || answer == undefined) {
                            is_send_api = false;
                            var html = '<div class="ness">请填写填空!</div>';
                            showprev(_self, html);
                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                    else {
                        if (answer == "" || answer == undefined) {

                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }

                //如果是打分提
                else if (_self.attr('data-type') == 3) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    answer = $(this).find('.score').attr('data-score');

                    if (necessary == 1) {
                        if (answer == 0 || answer == undefined) {
                            is_send_api = false;
                            var html = '<div class="ness">请打分!</div>';
                            showprev(_self, html);
                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                    else {
                        if (answer == "" || answer == undefined) {

                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }

                //如果是日期题
                else if (_self.attr('data-type') == 4) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    answer = $(this).find('input').val();

                    if (necessary == 1) {
                        if (answer == "" || answer == undefined) {
                            is_send_api = false;
                            var html = '<div class="ness">请选择日期!</div>';
                            showprev(_self, html);
                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                    else {
                        if (answer == "" || answer == undefined) {

                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }

                //如果是时间题
                else if (_self.attr('data-type') == 5) {

                    //问题ID
                    var question_id = $(this).attr('data-question_id');

                    //答案
                    var answer = "";

                    answer = $(this).find('input').val();

                    if (necessary == 1) {
                        if (answer == "" || answer == undefined) {
                            is_send_api = false;
                            var html = '<div class="ness">请选择时间!</div>';
                            showprev(_self, html);
                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                    else {
                        if (answer == "" || answer == undefined) {

                        }
                        else {
                            var data = {
                                question_id: question_id,
                                answer: answer
                            };
                            answerList.push(data);
                        }
                    }
                }

            });

            var jsonString = JSON.stringify(send_data);

            var pop_up = $('.pop-up');

            if (is_send_api) {
                API_Func('/questionnaires/answer', 'POST', {jsonString: jsonString}, false, function () {

                    $('.call_back').css('display', "block");

                }, function (d) {

                    $('.call_back').css('display', "none");

                    if (d.code == 0) {

                        location.href = 'publish_success.html?questionnaire_title=' + escape($('#questionnaire_name').val());

                    }
                    else {
                        pop_up_fn(pop_up, d.msg);
                    }


                }, function (d) {

                    $('.call_back').css('display', "none");

                    pop_up_fn(pop_up, d.msg);

                });
            }

            is_send_api = true;
        });


    });

    //退出分享
    function exit() {

        if (index) {
            var quitShare;
            quitShare = document.createElement('iframe');
            quitShare.style.display = 'none';
            document.documentElement.appendChild(quitShare);
            quitShare.src = "/quitShare_goBack";
        }
        else {
//            history.back(-1);
            location.href = 'index2.html';
        }

    }

    function showprev(obj, html) {
        var ness = obj.prev().hasClass('ness');

        if (ness) {
            //prev.remove();
        }
        else {
            obj.before(html);
        }
    }

    function hideprev(obj) {
        //如果之前有必填提示的就把它删掉
        var ness = obj.parents('.content_question').prev().hasClass('ness');
        var prev = obj.parents('.content_question').prev();
        if (ness) {
            prev.remove();
        }
    }

    //选择时间
    function selectDate(obj) {
        var currYear = (new Date()).getFullYear();
        var opt = {};
        opt.date = {preset: 'date'};
        opt.datetime = {preset: 'datetime'};
        opt.time = {preset: 'time'};
        opt.default = {
            theme: 'sense-ui', //皮肤样式
            display: 'bottom', //显示方式
            mode: 'scroller', //日期选择模式
            lang: 'zh',
            dateFormat: 'yyyy-mm-ddd',
            startYear: currYear - 10, //开始年份
            endYear: currYear + 10, //结束年份
            onSelect: function (valueText, inst) {//选择时事件（点击确定后），valueText 为选择的时间，
                var selectedDate = valueText + 1;
            }
        };
        var optDateTime = $.extend(opt['datetime'], opt['default']);
        obj.mobiscroll(optDateTime).date(optDateTime);
//        $(".content_question .time .time_input input").mobiscroll(optDateTime).time(optDateTime);
    }

    function selectTime(obj) {
        var currYear = (new Date()).getFullYear();
        var opt = {};
        opt.date = {preset: 'date'};
        opt.datetime = {preset: 'datetime'};
        opt.time = {preset: 'time'};
        opt.default = {
            theme: 'sense-ui', //皮肤样式
            display: 'bottom', //显示方式
            mode: 'scroller', //日期选择模式
            lang: 'zh',
            startYear: currYear - 10, //开始年份
            endYear: currYear + 10 //结束年份
        };
        var optDateTime = $.extend(opt['datetime'], opt['default']);
        obj.mobiscroll(optDateTime).time(optDateTime);
    }

    //键盘时间
    $(document).on('focus', '.desc', function (e) {

        $(".moreDiv").show();

        //文本框所在的div
        var documentHeight = $("#content").outerHeight(true) + $(".btnPublish").outerHeight(true);  //整个html高度

        var windownHeight = $(window).height();  //屏幕高度

//        var divHeight = $(".first-div").outerHeight(true) + $(".second-div").outerHeight(true) + $(".third-div").outerHeight(true); //键盘升起需要高于键盘的div总高度
        var divHeight1 = $(".content_title").outerHeight(true) + $(".content_welcome").outerHeight(true) + $(this).parents('.content_question').outerHeight(true);
        var divHeight2 = 0;
        $(this).parents('.content_question').prevAll().each(function () {
            divHeight2 += $(this).outerHeight(true);
        });
        var divHeight = divHeight1 + divHeight2;

        var keyboardHeight = windownHeight / 2;  //半屏
        var scrollHeight = divHeight + keyboardHeight - windownHeight;

        if (divHeight > windownHeight / 2) {
            //需要滑动
            var canScrollHeight = documentHeight - windownHeight;
//            console.log(canScrollHeight);
            if (canScrollHeight < scrollHeight) {
                //滑动距离不够
                var moreheight = (scrollHeight - canScrollHeight) / windownHeight * 100 + 'vh';
//                console.log(moreheight);
//                $("#content").append('<div class="moreDiv" style="width: 100%;height: ' + moreheight + '"></div>');
            }
            window.scrollTo(0, scrollHeight);
        }
    });

    //查看大图
    $(document).on('click', '.preview_img', function () {
        $.watchBigPic($(this));
    });

</script>